<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>javascript打印图形</title>
    <!-- 219971026 秦福将 -->
    <script>
        //打印三角形
        var a,b,c;
        for(a=1;a<=5;a++){//确定有5行
            for(b=1;b<=6-a;b++){
                document.write("&nbsp;");//空格
                document.write("&nbsp;");
            }
            for(c=1;c<=a;c++){
            document.write("*");//星星
            document.write("&nbsp;");
            document.write("&nbsp;");
            }
            document.write("<br>");//换行
        }
      //打印平行四边形
      var i,j,k;
      for(i=1;i<=5;i++)//确定有5行
      {
     for(j=1;j<=5-i;j++){
        document.write("&nbsp");//空格
        document.write("&nbsp");
     }
     for(k=1;k<=5;k++){
        document.write("*");//星星
        document.write("&nbsp");
        document.write("&nbsp");
     }
     document.write("<br>");//换行
     }
    </script>
</head>
<body>
    
</body>
</html>
